package com.station.administrators.service.impl;


import com.open.capacity.common.model.OrderModel;
import com.station.administrators.dao.OrderDao;

import com.station.administrators.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author YangGang
 * @Description: TODO
 * @date 2021/6/25/9:48
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderDao orderDao;

    @Override
    public void update(OrderModel orderModel) {
        if(orderModel.getOrdeid()!=null){
            orderDao.update(orderModel);
        }else {
            orderDao.add(orderModel);
        }

    }

    @Override
    public void delete(Long id) {
        orderDao.delete(id);
    }

    @Override
    public OrderModel findById(Long id) {
        return orderDao.findById(id);
    }

    @Override
    public List<OrderModel> findAll(OrderModel orderModel) {
        Integer page = orderModel.getPage();
        Integer limit = orderModel.getLimit();
        page=(page-1)*limit;
        orderModel.setPage(page);
        return orderDao.findAll(orderModel);
    }

    @Override
    public Integer getCount(OrderModel orderModel) {
        return orderDao.getCount(orderModel);
    }

    @Override
    public void updates(OrderModel orderModel) {
        orderDao.updates(orderModel);
    }
}
